class Solution {
public:
    int ret=0;
    int path=0;
    int n;
    int t;
    int findTargetSumWays(vector<int>& nums, int target) {
        n=nums.size();
        t=target;
        dfs(nums,0);
        return ret;
    }   
    void dfs(vector<int>&nums,int i)
    {
        if(i==n)
        {
            if(path==t)
            {
                ret++;
            }
            return;
        }

        path+=nums[i];
        dfs(nums,i+1);
        path-=nums[i];
        
        path+=-nums[i];
        dfs(nums,i+1);
        path-=-nums[i];
    }
};